package com.eastedu.report.common.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 直播参与:0; 回看参与:1; 参与:2; 未参与:3',
 *
 * @author superman
 */
@Getter
public enum JoinType {
    /**
     * Live join type.
     */
    LIVE("0", "直播参与"),
    /**
     * Look back join type.
     */
    LOOK_BACK("1", "回看参与"),
    /**
     * Join join type.
     */
    JOIN("2", "参与"),
    /**
     * Not join join type.
     */
    NOT_JOIN("3", "未参与");

    private final String code;
    private final String desc;

    JoinType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * Gets join type.
     *
     * @param code the code
     * @return the join type
     */
    public static JoinType getJoinType(String code) {
        for (JoinType joinType : JoinType.values()) {
            if (Objects.equals(joinType.getCode(), code)) {
                return joinType;
            }
        }
        return NOT_JOIN;
    }

}
